<?php


$line = array('ACCOUNT_NUMBER', 'TITLE', 'REASON', 'RESULT', 'PRODUCT', 'NOTES', 'DIRECTION', 'TYPE', 'INTERACTION_DATE', 'EXECUTION_DATE');
$csv->addRow($line);



WHILE($r = mysql_fetch_array($result))
  {
    $pid = $r["pid"];
    $result2 = mysql_query("SELECT * FROM interactions WHERE project_id = '$pid'");
	$row2 = mysql_fetch_array($result2);

	$title = $row2["title"];
	$reason = $row2["reason"];
	$result2 = $row2["result"];
	$product = $row2["product"];
	$notes = $row2["notes"];
	$direction = $row2["direction"];
	$type = $row2["type"];
	$interactiondate = date("d.m.Y H:i");
	$executiondate = date("d.m.Y H:i");
    
    $line = array($r['account_number'], $title, $reason, $result2, $product, $notes, $direction, $type, $interactiondate, $executiondate);
    $csv->addRow($line);
  }

$datum = date("d.m.Y");
$end = ".csv";
$title = "Export_ManualMoves_Interactions_".$datum.".csv";
echo $csv->render($title);


?>